﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GcmpGuiMainFrame.h"
#include "IStatusBar.h"

#include <QStatusBar>

class QHBoxLayout;

namespace gcmp
{

    class IStatusBarPanel;

    /// \brief StatusBarImpl状态栏实现类
    ///
    /// 基于Qt状态栏实现Gcmp状态栏行为和状态功能
    class GCMP_GUI_MAIN_FRAME_EXPORT StatusBarImpl : public QStatusBar, public IStatusBar
    {
        Q_OBJECT
    public:
        explicit StatusBarImpl(QWidget* pParent = nullptr);
        ~StatusBarImpl() final;

        IStatusBarPanel* GetPanel(const std::wstring& panelName) const final;

        bool AppendPanel(OwnerPtr<IStatusBarPanel> pPanel, StatusBarAlignment alignment) final;

        bool InsertPanel(const std::wstring& followingPanelName, OwnerPtr<IStatusBarPanel> pPanel) final;

        bool DeletePanel(const std::wstring& panelName) final;

        virtual void UpdateControlStatus() override;

    private:
        std::vector<IStatusBarPanel*> m_leftPanels;     // 左边按顺序从左向右添加
        std::vector<IStatusBarPanel*> m_rightPanels;    // 右边按顺序从右向左添加

        QHBoxLayout* m_pLayout;
    };

}   // end namespace gcmp
